This happens for two reasons:
1. Students aren't used to writing for 45-60 minutes straight anymore. We often take breaks if we're writing, or simply do most of our composition on a computer--we type.
2. Students are nervous and grip their pens harder than they usually do because of stress.

Solutions:
1. Not much you can do about this on the day of the in-class essay...but you can write "by hand" daily to build up your stamina if this is a big issue for you.
--You can also put your pen down and stretch your fingers while you are rereading what you just wrote, or looking up quotes.
2. RELAX. Remember, this is an opportunity to show your ability, not an excuse for your teacher to judge you unworthy! You won't get kicked out of school for doing poorly on one essay, and if you really bomb, you will probably have another chance to show off.
--If you find you have a death grip on your pen, put it down and wipe your palm on your pants leg, or flex your fingers once or twice.